<?
	require_once('../Extras/Functions.php');
	CheckSession();
	
	$Colonia = new Colony($_SESSION['s_ColID']);
	$mysqli = ConectObj();
	$query = 'SELECT log.ID,log.Type,log.Value,cols.Colonia AS Col1,cols2.Colonia AS Col2 FROM log JOIN (cols,cols AS cols2) ON (log.Col1=cols.ID AND log.col2=cols2.ID) WHERE Col1='.$Colonia->ID.' OR Col2='.$Colonia->ID.' ORDER BY log.ID DESC LIMIT 20';
	if($result = $mysqli->query($query)){/*Usamos esto en la tabla*/}
	else
		echo 'Error al tomar datos de log.<br>'.$mysqli->error.'<br>'.$query;
	
	//Imprimo Reloj
	require("../Extras/Reloj.php");
?>
<link rel="stylesheet" href="../Extras/StylePrincipal.css">
<script type="text/javascript">
	$(document).ready(function(){
		
	});
</script>
<div align="center">
	<p>Lista de ataques recientes.</p>
	<table>
		<thead>
			<tr><th>ID</th><th>Info</th></tr>
		</thead>
		<tbody>
			<?
				while($log = $result->fetch_object()){
					if($log->Type == 'AtaInv' && $log->Value > 0)
						$str = '<a class="Pos">'.$log->Col1.' lanzo un ataque sobre '.$log->Col2.' y capturo '.$log->Value.' Hectareas</a>';
					elseif($log->Type == 'AtaInv' && empty($log->Value))
						$str = '<a class="Neg">'.$log->Col1.' trato de invadir a '.$log->Col2.' pero fallo el ataque... pfff que noob</a>';
					elseif($log->Type == 'AtaSaq' && $log->Value > 0)
						$str = '<a class="Pos">'.$log->Col1.' saqueo a '.$log->Col2.' y se llevo '.$log->Value.' en Oro, Comida, Piedras y Runas';
					elseif($log->Type == 'AtaSaq' && empty($log->Value))
						$str = '<a class="Neg">'.$log->Col1.' intento saquear a '.$log->Col2.' pero no pudo contra su defensa';
					else
						$str = $log->Col1.' -> '.$log->Col2.' -> '.$log->Type.'('.$log->Value.')';
						
					echo'<tr><td>'.$log->ID.'</td><td>'.$str.'</td></tr>';
				}
			?>
		</tbody>
		<tfoot>
			<tr><td colspan="5"></td></tr>
		</tfoot>
	</table>
</div>